// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import ComponentBase from "../../BASE/ComponentBase";
import equipment from "../../BASE/equipment";
import realThing from "../../BASE/realThing";
import A110 from "../../equipment/weapon/Dao/A110";





const {ccclass, property} = cc._decorator;

@ccclass
export default class Shops extends ComponentBase {

  @property(cc.SpriteAtlas)
  A1_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A1_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A1_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A1_8: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A2_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A2_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A2_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A2_8: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A3_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A3_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A3_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  A3_8: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  B_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 B_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 B_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 B_8: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
  C_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
C_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 C_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 C_8: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
D_2: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 D_4: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 D_6: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteAtlas)
 D_8: cc.SpriteAtlas = null;//通用图集
 @property(cc.SpriteAtlas)
 FU: cc.SpriteAtlas = null;//通用图集
  @property(cc.SpriteFrame )
  A:cc.SpriteFrame = null;//通用图集
  @property(cc.Prefab )
  tishi:cc.Prefab  = null;//通用图集






   items: { [key: string]: string } = {
        "A110": "废铁",
        "A131": "快刀",
        "A132": "有点长的刀",
        "A151": "轻刃",
        "A152": "不寻长的刀",
        "A121": "斧头",
        "A122": "菜刀",
        "A125": "鸡剑",
        "A126": "桃木剑",
        "A127": "弯刀",
        "A128": "物理学圣剑",
        "A141": "巨剑",
        "A142": "镰刀",
        "A143": "水晶剑",
        "A144": "淬血剑",
        "A145": "道法剑",
        "A146": "狂战斧",
        "A147": "樊剑",
        "A161": "圣骑士之剑",
        "A162": "死神之镰",
        "A164": "尚方宝剑",
        // ... 其他物品
        "FU0": "火符",
        "FU1": "石符",
        "FU2": "水符",
        "FU3": "风符",
    };

     getItemNameById(id: string): string | undefined {
        return this.items[id];
    }










  find(face:number,th:string){
  let Tatlas=this.A1_4;
if (th!=null) {
  
console.log(th)
if (th=="D10") {
  return this.A
}

if (th=="D16") {
  return Shops.find(2,"D16-b")
}
if (th[0]=="F") {
switch (th[2]) {
  case "0":  return this.FU.getSpriteFrame("fire")
    
    break;
    case "1":  return this.FU.getSpriteFrame("mud")
    
    break;
    case "2":  return this.FU.getSpriteFrame("water")
    
    break;
    case "3":  return this.FU.getSpriteFrame("wind")
    
    break;
  default:
    break;
}



}
if (face==10) {
  switch (th[0]) {
case "B":Tatlas=this.B_2
break;
case "C":Tatlas=this.C_6;
break;
case "D":Tatlas=this.D_2;
break;
case "A": switch (th[1]) {

case "1":Tatlas=this.A1_6
break;
case "2":Tatlas=this.A2_6
break;
case "3":Tatlas=this.A3_2
break;}



  } 
}else{



  switch (th[0]) {
    case "B":switch (face) {
       
      case 2:Tatlas=this.B_2;
      break;
      case 4:Tatlas=this.B_4
      break;
      case 6:Tatlas=this.B_6
      break;
      case 8:Tatlas=this.B_8
      break;}
      break;
      case "D":switch (face) {
       
        case 2:Tatlas=this.D_2;
        break;
        case 4:Tatlas=this.D_4
        break;
        case 6:Tatlas=this.D_6
        break;
        case 8:Tatlas=this.D_8
        break;}
      break;
      case "C":switch (face) {
       
        case 2:Tatlas=this.C_2;
        break;
        case 4:Tatlas=this.C_4
        break;
        case 6:Tatlas=this.C_6
        break;
        case 8:Tatlas=this.C_8
        break;}
      break;
    default:switch (th[1]) {
      case "1":switch (face) {
       
        case 2:Tatlas=this.A1_2;
        break;
        case 4:Tatlas=this.A1_4
        break;
        case 6:Tatlas=this.A1_6
        break;
        case 8:Tatlas=this.A1_8
        break;
      
        default:
          break;
      } break;
      case "2":switch (face) {
       
        case 2:Tatlas=this.A2_2
        break;
        case 4:Tatlas=this.A2_4
        break;
        case 6:Tatlas=this.A2_6
        break;
        case 8:Tatlas=this.A2_8
        break;
      
        default:
          break;
      } break;

      case "3":switch (face) {
       
        case 2:Tatlas=this.A3_2
        break;
        case 4:Tatlas=this.A3_4
        break;
        case 6:Tatlas=this.A3_6
        break;
        case 8:Tatlas=this.A3_8
        break;
      
        default:
          break;
      } break;

      case "4":switch (face) {
       
        case 2:Tatlas=this.A1_2
        break;
        case 4:Tatlas=this.A1_4
        break;
        case 6:Tatlas=this.A1_6
        break;
        case 8:Tatlas=this.A1_8
        break;
      
        default:Tatlas=this.A1_2
          break;
      } break;
    
        
       
      default:Tatlas=this.A1_4
        break;
    }
      break;
  }
  if (Tatlas==null) {
    Tatlas=this.A1_4
  }
}
console.log(Tatlas)
console.log(Tatlas.getSpriteFrame(th))
  if (Tatlas.getSpriteFrame(th)!=null||Tatlas.getSpriteFrame(th.toLowerCase())!=null) {
   if (th[0]=="A"&&Tatlas.getSpriteFrame(th.toLowerCase())) {
    return Tatlas.getSpriteFrame(th.toLowerCase());
   }else  return Tatlas.getSpriteFrame(th);
   
  
  }
 else{ console.log(th) ;return Tatlas.getSpriteFrame("a110");}
}else return null

}
  

PM(w:string){

if(w[1]=="3"){return this.find(2,w)}else{return this.find(6,w)}



}


start(): void {

}
getg(){


  return this.A
}

}